/* 个性化设置
 * @Author: wujie 
 * @Date: 2018-06-12 11:06:22 
 * @Last Modified by: wujie
 * @Last Modified time: 2018-06-27 11:02:57
 */
import React,{ Component } from 'react'
import { Row } from 'antd'
import components from '@/components'
import { connect } from 'react-redux'
import actions from '@/actions/individuationSetting'
import util from '@/utils'

const { IndividuationSettingForm, Card } = components

class IndividuationSetting extends Component {

  render(){

    const props = util.pick(this.props, [
      'account', 
      'smsNum', 
      'ip', 
      'receiveUrl', 
      'remindPhone', 
      'remindValue',
      'saveButtonLoading',
    ])

    const funProps = util.pick(this, [
      'onChangeIp',
      'onChangeReceiveUrl',
      'onChangeRemindPhone',
      'onChangeRemindValue',
      'onSave',
    ])

    return (
      <div>
        <Card title="个性化设置">
          <Row style={{backgroundColor: '#fff', padding: 24}}>
            <IndividuationSettingForm 
              {...props}
              {...funProps}
            />
          </Row>
        </Card>
      </div>
    )
  }

  componentDidMount() {
    this.props.getData()
  }

  onChangeIp = ({ target: { value }}) => {
    this.props.setIp(value)
  }

  onChangeReceiveUrl = ({ target: { value }}) => {
    this.props.setReceiveUrl(value)
  }

  onChangeRemindPhone = ({ target: { value }}) => {
    this.props.setRemindPhone(value)
  }

  onChangeRemindValue = ({ target: { value }}) => {
    this.props.setRemindValue(value)
  }

  onSave = () => {
    this.props.updateData()
  }

} 

const mapStateToProps = (({ individuationSettingReducer }) => ({ ...individuationSettingReducer }))

const mapDispatchToProps = { ...actions }

export default connect(mapStateToProps, mapDispatchToProps)(IndividuationSetting)
